﻿@model IEnumerable<AutoPartsSearch.Domain.Entities.Dictionary>

@{
    ViewBag.Title = "List";
    Layout = "~/Areas/Administration/Views/_Layout.cshtml";
}
<h2>List</h2>
<fieldset>
    <div>
         <span>Тип: </span>  @Html.DropDownList("dictTypes", (IEnumerable<SelectListItem>)ViewBag.DictionaryTypes)
    </div>
    <p>
        @Html.ActionLink("Добавить", "Add", "Dictionary")
    </p>
    <table id="step1" class="table-form">
        <thead>
            <tr>
                <th></th>
                <th>Id</th>
                <th>Тип</th>
                <th>Ru</th>
                <th>Ro</th>
                <th>En</th>
                <th>Parent Id</th>
                <th>Родитель</th>
                <th>Дополнительный Родительский Id</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var dict in Model)
            {
                <tr>
                    <td>
                        @Html.ActionLink("Редактировать", "Edit", new { id = dict.Id}, new {@class = "editButton"})
                    </td>
                    <td>@dict.Id</td>
                    <td>@dict.Type.ToString()</td>
                    <td>@dict.Name.Ru</td>
                    <td>@dict.Name.Ro</td>
                    <td>@dict.Name.En</td>
                    <td>@dict.ParentId</td>
                    <td>@dict.ParentName.Default</td>
                    <td>@dict.AdditionalParentId</td>
                    <td>
                        @using (Html.BeginForm("Delete", "Dictionary", new { id = dict.Id }))
                        {
                            <input type="submit" value="Удалить" class="deleteButton" />
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
    
</fieldset>

@section Scripts
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dictTypes').change(function () {
                var url = "@Url.Action("List", "Dictionary")";
                url = url + "?dictionaryType=" + $(this).val();
                window.location = url;
            });
        });
    </script>
}



